(($) => {
	$(window).keyup(function (e) {
		let nodes = LeftTree.ztree.getSelectedNodes();
		let node = nodes.length > 0 ? nodes[0] : null;
		
		let activeElement = document.activeElement;
		
		if (activeElement) {
			let activeElementName = document.activeElement.tagName.toLowerCase();
			
			if(['input', 'textarea'].indexOf(activeElementName) != -1) {
				return;
			}
		}
		
		let $search_input = $('#search_input');
		
		switch (e.keyCode) {
			case COREVAR.KEYS.F3:
				$search_input.focus();
				break;
				
			case COREVAR.KEYS.ESC:
				$search_input.val('');
				SearchController.htmlSearchToggle();
				break;
				
			case COREVAR.KEYS.F2:
				if (node) {
					LeftTree.ztree.editName(node);
				}
				break;
				
			case COREVAR.KEYS.DELETE:
				if (node) {
					LeftTree.ztree.removeNode(node, true);
				}
				break;
				
		}
	});
})(jQuery);